﻿using System;

namespace Metro.Kashikoi.Common
{
    /// <summary>
    /// This class provides bease class of <c>IDisposable</c>.
    /// </summary>
    public abstract class Disposable : IDisposable
    {
        /// <summary>
        /// Disposings this instance.
        /// </summary>
        public abstract void Disposing();

        #region IDisposable Members

        ~Disposable()
        {
            Dispose(false);
        }

        /// <summary>
        /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
        /// </summary>
        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }

        private bool disposed = false;
        protected virtual void Dispose(bool disposing)
        {
            if (!this.disposed)
            {
                if (disposing)
                {
                    Disposing();
                }

                disposed = true;
            }
        }

        #endregion
    }
}
